package demo1;
    public class Test {

        public static void main(String[] args) {
            Animal animal = new Bird("小鸟",2);

            Bird bird = (Bird)animal;

            bird.fly();

            System.out.println("=============");

            Animal animal2 = new Dog("单身狗",10);
            //animal2 这个引用 是否引用了 Bird这个对象
            if(animal2 instanceof Bird) {
                Bird bird2 = (Bird) animal2;

                bird2.fly();
            }else {
                System.out.println("animal2 instanceof Bird not!!!!");
            }
        }

        public static void func(Animal animal) {
            animal.eat();
        }

        public static int add(int a,int b) {
            return a+b;
        }

        public static int add(int a,int b,int c) {
            return a+b+c;
        }

        public static void main3(String[] args) {
            add(1,2);
            add(1,2,3);
        }

        public static void main2(String[] args) {
            Dog dog = new Dog("旺财",10);
            func(dog);
            System.out.println("======");
            Bird bird = new Bird("小鸟",2);
            func(bird);
        }
        public static void main1(String[] args) {
            Animal animal = new Dog("旺财",10);
            animal.eat();
        }
    }

